<template>
  <div>
    <h2>患者体温监测</h2>
    <p>患者姓名：{{ patient.name }}</p>
    <input type="number" step="0.1" v-model.number="patient.temperature" placeholder="请输入体温"/>
    <p>当前体温：{{ patient.temperature.toFixed(1) }}</p>
    <p>体温状态：{{ getTemperatureStatus(patient.temperature) }}</p>
    <p v-if="highFeverWarning" class="warning">高温警报！</p>
    
  </div>
</template>
<style>
.warning{
  color:red;
  font-weight: bold;
}
</style>
<script setup>
import { reactive, ref,watch } from 'vue'

// 患者数据
const patient = reactive({
  name:'王昊',
  temperature:36.5
})
const getTemperatureStatus = (temp) => {
  if (temp < 36) return '体温过低'
  if (temp <= 37.2) return '正常体温'
  if (temp <= 38) return '低烧'
  if (temp <= 39) return '高烧'
  return '超高热'
}
  const highFeverWarning = ref(false)
  watch(()=>patient.temperature,(newTemp,oldTemp)=>{console.log('新体温：${newTemp}°C(原体温：${oldTemp})°C')
    if(newTemp>=40)
    highFeverWarning.value = true;
  else
  highFeverWarning.value = false;
  }

  )

</script>